Skip to content

don't need to count realised parameters#12

Closed
michaelficarra wants to merge 1 commit intotc39:mainfrom
michaelficarra:patch-2
Closed

don't need to count realised parameters#12
michaelficarra wants to merge 1 commit intotc39:mainfrom
michaelficarra:patch-2

Conversation

@michaelficarra
Copy link
Copy Markdown
Member

This is simpler and doesn't introduce new phrasing. I've also changed the semantics when the argument is missing from throwing to no-op.

@ljharb
Copy link
Copy Markdown
Member

ljharb commented Nov 12, 2025

It was intentional to throw an error when the setter gets zero arguments; that shouldn't be valid for any setter. I can certainly use the "is present" verbiage tho.

@michaelficarra
Copy link
Copy Markdown
Member Author

There are 3 existing built-in setters in the language and none of them throw when the parameter is not present.

  1. https://tc39.es/ecma262/#sec-object.prototype.valueof
  2. https://tc39.es/ecma262/#sec-iterator.prototype-%symbol.tostringtag%
  3. https://tc39.es/ecma262/#sec-iterator.prototype.constructor

@ljharb
Copy link
Copy Markdown
Member

ljharb commented Nov 12, 2025

Sure - that doesn't mean that's a good precedent, it just means there's precedent to be sloppy. There's precedent to coerce, too, but we chose to change that because it was a bad decision - similarly, having a function that should only ever be called with precisely 1 argument noop when called with zero seems like an oversight to me.

(it's also notable that one of those is legacy, and the other two are web compatibility hacks - so probably not great examples to look at for precedent anyways)

@ljharb
Copy link
Copy Markdown
Member

ljharb commented Nov 18, 2025

Closing, per today's plenary and 377c7e7

@ljharb ljharb closed this Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants